package activity

import (
	"activity_srv/activityclient"
	"api/internal/respons"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetGrouponProductListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetGrouponProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGrouponProductListLogic {
	return &GetGrouponProductListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetGrouponProductListLogic) GetGrouponProductList(req *types.GetGrouponProductListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.ActivityRpc.GetGrouponProductList(l.ctx, &activityclient.GetGrouponProductListRequest{
		ProductName: req.ProductName,
	})
	if err != nil {
		return respons.Error(400, "拼团商品列表展示失败", err.Error()), err

	}
	return respons.Success(list), nil
}
